package huawei.js2025;

/**
 * 停车场最大距离
 */
public class Question2 {

    public int parkingLotMaxLen(String s) {
        int start = -1;
        int maxLen = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                int len = 0;
                if (start == -1) {
                    len = i - 1;
                } else {
                    len = (i - start - 1) / 2;
                }
                maxLen = Math.max(maxLen, len);
                start = i;
            }
        }

        if (s.charAt(s.length() - 1) != '1') {
            maxLen = Math.max(maxLen, (s.length() - 1) - start - 1);
        }

        return maxLen;
    }

    public static void main(String[] args) {
        Question2 q = new Question2();
        System.out.println(q.parkingLotMaxLen("0100001"));
    }
}
